import type { Unit } from './common'
export type ItemCommonKey = 'id' | 'name'
// 出库单
// 获取出库单主表参数接口
export interface Params {
	page: number
	rows: number
	r: {
		businessDate: string[]
	}
	orl: {
		sysBillCode: string
	},
	i: {
		billState?: (number|string)[]
		billType: (number|string)[]
		billBizTypeId: (number|string)[]
		organId: (number|string)[]
		otherOrganId: (number|string)[]
		checkAcceptStatus: (number|string)[]
	},
	o: {
		sysBillCode: string
	},
	ri: {
		'detail-outHouseId': (number|string)[]
	}
}
// 业务日期区间接口
export interface BusinessDate {
	begin: string
	end: string
}
export interface FilterOrgan {
	id: string
	name: string
}
// 出库单筛选条件接口
export interface FilterData {
	businessDate: string[]
	organId: string[]
	otherOrganId: string[]
	detailOutHouseId: string[]
	checkAcceptStatus: string[]
}
// 选项接口
export interface OrganItem {
	id: string
	name: string
}
// 单据类型选项接口
export interface BillTypeItem {
	id: number
	name: string
	visibleFlag?: boolean
}
// 附件队列接口
export interface AppendicesItem {
	appendixUrl: string
}
// 品项类别接口
export interface ItemType {
	id: string
	name: string
}
// 品项单位接口
export interface ItemUnit extends Partial<Unit> { }

// 品项明细接口
export interface ItemDetail {
	id: string
	billId?: string
	item: {
		id?: string
		name?: string
		itemType?: string
		canWeigh?: number
		assistUnit?: string
		itemUnitList?: ItemUnit[]
		code?: string
		spec?: string
		itemTypeRef?: {
			name: string
		}
		shelfLife?: number
		shelfLifeFlag?: boolean
		storageMethod?: number
		imageUrl?: string
		kgToMainUnit?: number
	}
	amount?: number
	itemUnit?: ItemUnit
	outHouse?: {
		id?: string
		name?: string
	}
	inHouse?: {
		id?: string
		name?: string
	}
	inTaxPrice?: number
	inTaxMoney?: number
	salesTaxPrice?: number
	salesPrice?: number
	salesTaxMoney?: number
	salesMoney?: number
	salesTaxRate?: number
	salesTaxRateMoney?: number
	taxRate?: number
	strategy?: number
	checked?: boolean
	stock?: number
	assistUnit?: string
	assistUnitAmount?: number | string
	weightList?: object[]
	productDate?: string
	memo?: string
	rootItemType?: ItemType
	weighRecords?: object[]
	weighImages?: object[]
	weighCountFlag?: number
	outReason?: {
		id?: string
		name?: string
	}
	price?: number
	money?: number
	batchCode?: number
	expectArrivalDate?: string
	fxSortNum?: number
	outStockSign?: number
	moneyChange?: boolean
	originalAmount?: number
	$fxCalculation?: string
	giftFlag?: boolean
	preDetailIsAssistUnit?: boolean
	freight?: string
	stockOrderAmount?: number
	mainUnitId?: string
	distributeFlag?: boolean
}
// 单据业务类型接口
export interface BillBizTypeItem {
	id: string
	name: string
}
// 未分拣品项信息接口
export interface ItemInfo {
	id: string
	name: string
	itemType: string
	canWeigh: number
	assistUnit: string
	itemUnitList: object[]
	rootItemType: ItemType
	code?:string
}
// 单据信息接口
export interface BillDetail {
	id: string
	billSign?: number
	billType: number
	billClass?: string
	subBillType: number
	billTypeName: string
	billState: number
	checkAcceptStatus?: number
	recheckState?: number
	sysBillCode: string
	sortState: string
	businessDate: string
	singleHouseFlag: number
	billBizType: {
		id: string
		name: string
	}
	billBizTypeId: string
	organ: {
		id: string
		name?: string
	}
	otherOrgan: {
		id: string
		organType?: string
		name?: string
	}
	outHouse: {
		id: string
		name?: string
	}
	operateMan: {
		id: string
		name?: string
	}
	version: number
	details: ItemDetail[]
	appendixes: AppendicesItem[]
	userBillCode?: string
	memo? :string
	carriageFee: number
	detailAmount: number
	noOutStoreItems?: ItemInfo[]
	noOutStoreItemDetails?: ItemDetail[]
	noOutStoreDetails?: ItemDetail[]
	outStoreTypes?: ItemType[]
	noStoreTypes?: ItemType[]
	weightItemTypeTree?: ItemType[]
	noWeightItemTypeTree?: ItemType[]
	expressDeliveryCompanyName?: string
	expressDeliveryNumber?: string
	// 0 pad新建   1 供应链创建
	autoType?: number,
	parentBill?: object,
	actualSellerId: number,
    actualSellerName: string
}

// 品项价格接口
export interface PriceData {
	price: number
	refPrice: boolean
	strategy: number
	taxPrice: number
	taxRate: number
	unitId: string
}
// tag选项接口
export interface TagSelectItem {
	id: string|number
	label: string
}
// 品项数据接口
export interface ItemData {
	id: string
	item: Record<string, unknown>
	amount: number
	originalAmount: number
	$fxCalculation: string
	salesTaxRate: number
	salesTaxPrice: number
	salesPrice: number
	salesTaxMoney: number
	salesMoney: number
	itemUnit: Record<string, unknown>
	mainUnitId?: string
	inHouse: Record<string, unknown>
	giftFlag: boolean
	preDetailIsAssistUnit: boolean
	outReason:Record<ItemCommonKey, string>
	batchCode?:string
	stock?: string
	freight?: string
	outHouse?: Record<string, unknown>
	distributeFlag?: string
	memo?: string
	productDate?: string
	stockOrderAmount?: number
	assistUnitAmount?: number
	price?: number
	money?: number
	salesTaxRateMoney?: number
}
// 异常警告返回值接口
export interface MistakeCheckResponse {
	checkResult: boolean
	errorDetailList: []
	minStep: string
}

// vueRef类
// 异常警告vue实例接口
export interface MistakeCheckRef {
	mistakeCheck: (type: string) => void
	showMistakeCheck: boolean
}
// 称重面板vue实例接口
export interface ScalesContainerRef {
	openScales: (detailsList:ItemDetail[], item:ItemDetail) => void
}

export interface OrderBill {
	id:string
	checked: boolean
	billState?: number
}
